package com.base.cn.platform.os.controller.mobile.course.record;

import com.base.cn.platform.os.common.MobileBaseController;
import com.base.cn.platform.os.service.course.cou.record.CourseLearnFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Map;

/**
 * 课程播放记录
 *
 * @author zjh
 * @since 2018-12-14
 **/
@Controller
@RequestMapping("/mobile/uc/course/play/Flow")
public class MobileCourseLearnFlowController extends MobileBaseController {

    @Autowired
    CourseLearnFlowService  courseLearnFlowService;
    /**
     * 保存课程播放学习记录
     *
     * @param playRecordFlow 课程播放记录
     */
    @RequestMapping("/savePlayRecordFlow")
    @ResponseBody
    public Map<String, Object> savePlayRecordFlow(HttpServletRequest request,
                                                  @RequestBody Map<String, Object> playRecordFlow) {
        BigDecimal userId = webMobileLoginUtil.getLoginUserId(request);
        playRecordFlow.put("userId", userId);
        playRecordFlow.put("source", 2);
        Integer finish = Integer.valueOf( playRecordFlow.get("finish").toString());
        return courseLearnFlowService.saveCourseLearnFlow(playRecordFlow,finish);
    }
}
